<template>
  <a-modal
    title="上传文件"
    :width="450"
    :visible="visible"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-form-model ref="form" :model="formData" :rules="validatorRules">

      <a-form-model-item label="文件描述" prop="fileDesc">
        <a-textarea
          v-model="formData.fileDesc"
          placeholder="请输入文件描述"
          :auto-size="{ minRows: 3, maxRows: 5 }"
        />
      </a-form-model-item>
      <a-form-model-item label="文件上传" prop="fileList">
        <aee-file-upload v-model="formData.fileList" :file-desc="fileDesc" :depart-file="departFile"
                         :button-visible="clickAbled" :current-path="currentPath"
                          :depart-id="departId"
        ></aee-file-upload>
      </a-form-model-item>
<!--      <a-form-model-item label="文件上传" prop="fileList">-->
<!--        <j-upload v-model="formData.fileList" ></j-upload>-->
<!--      </a-form-model-item>-->



    </a-form-model>
  </a-modal>
</template>

<script>
import AeeFileUpload from './AeeFileUpload'
import JUpload from '@/components/jeecg/JUpload'
export default {
  name: "UploadModal",
  props:{
    path:String,
    departFile:{
      type:Boolean,
      required:true,
      default:false
    },
    departId:{
      type:String,
      required:false,
      default:""
    },
  },
  components: {
    AeeFileUpload
  },
  data() {
    return {
      visible: false,
      formData: {fileDesc: ""},
      validatorRules: {
        fileList: [{required: true, message: '请选择文件上传'}],
        fileDesc: [{required: true, message: '请输入文件描述，方便查找'}],
      },
    }

  },
  computed:{
    clickAbled:{
      get(){
       let j= this.formData.fileDesc.length>0;
        return j;
      }
    },
    fileDesc:{
      get() {
        return this.formData.fileDesc;
      }
    },
    currentPath() {
      if(this.path==='null'){
       return null;
      }

      return this.path;
    }
  },
  methods: {
    clear() {
      this.visible = false;
      this.$refs.form.resetFields();
    },
    show() {
      this.visible = true
    },
    handleOk: function () {
     this.$emit("ok");
      this.clear();

    },
    handleCancel: function () {
      this.clear();

    }

  }

}
</script>

<style scoped>

</style>